//
//  DDTBaseViewController.swift
//  weibo
//
//  Created by mac on 16/9/22.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit
import SVProgressHUD

class DDTBaseViewController: UIViewController {

    // 用户是否登入标志
    var userLogin = false

    
    override func viewDidLoad() {
        super.viewDidLoad()

        if userLogin {
            self.view = tableView
            //设置tabelView代理方法
            tableView.dataSource = self
            tableView.delegate = self
  
            
        }else {
            
            setupVisitor()
            
        }
    }
    
    
    
    
    
    //设置访客
    private func setupVisitor() {
        self.view = visitorView

        if self is DDTHomeViewController {
            visitorView.startRotationAnimation()
        }
        else if self is DDTMessageViewController {
                    visitorView.setUpVisitorInfo("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }
        else if self is DDTDiscoverViewController {
                    visitorView.setUpVisitorInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }
        else if self is DDTProfileViewController {
                    visitorView.setUpVisitorInfo("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        visitorView.visitorViewDelegate = self
        
        //导航栏两个按钮
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLogin")
        
        
        
    }



    //懒加载访客视图
    private lazy var visitorView: DDTVisitorView = DDTVisitorView()

    //懒加载tableView
    lazy var tableView:UITableView = UITableView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))

    

}

// MARK: - 注册,登陆 代理
extension DDTBaseViewController: DDTVisitorViewDelegate {
    func visitorViewRegister() {
        print("代理注册")
        SVProgressHUD.showSuccessWithStatus("点击了注册")
    }
    
    //登陆界面
    func visitorViewLogin() {
        print("代理登陆")
        
        let OauthVc = DDTOauthViewController()
        //切换控制器
        self.presentViewController(UINavigationController(rootViewController: OauthVc), animated: true, completion: nil)
    }
    
    
}

// MARK: - tabelView代理方法

extension DDTBaseViewController: UITableViewDataSource {
    func tableView( tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 0
    }
    
  
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
     return UITableViewCell()
    }

    
}
extension DDTBaseViewController: UITableViewDelegate {
    
}


